package com.heima.user.controller.v1;

import com.alibaba.fastjson.JSON;
import com.heima.model.common.dtos.app.UserRelationDto;
import com.heima.model.common.dtos.common.ResponseResult;
import com.heima.model.user.pojos.ApUser;
import com.heima.user.service.ApUserFanService;
import com.heima.user.service.ApUserFollowService;
import com.heima.user.service.ApUserService;
import jdk.nashorn.internal.ir.annotations.Reference;
import org.checkerframework.checker.units.qual.A;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/api/v1/user")
public class ApUserFanFollowController {
    @Autowired
    private ApUserService apUserService;
    @GetMapping("/user")
    public ResponseResult getUser(@RequestParam String userId){
        ApUser apUser = apUserService.getById(userId);
        return ResponseResult.okResult(JSON.toJSONString(apUser));
    }
    /**
     * 关注功能
     * @param dto
     * @return
     */
    @PostMapping("/user_follow")
    public ResponseResult userFollow(@RequestBody UserRelationDto dto) {
        return apUserService.follow(dto);
    }
}
